<%--
 *  File:    ProtocolConfManagement.jsp	
 *  @Author: TendyHu
 *  Date:    2010/09/17
 *
 *  Copyright (C) 2000 - 2010 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval"%>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom"%>

<%
	
  //init param
  String privilegeCode = "11201";
  String strTableName = "v_protocolconfmanage";  
  String strModuleName = "COM";
  String contextPath = request.getContextPath();
%>
<%@ include file="/inc/CommonHeader.inc"%>
<%@ include file="/inc/OvalLocationDefault.inc"%>
<%@ include file="/inc/Print.inc"%>

<html>
<head>
<title>ProtocolConfManagement</title>
<PageFlow:CheckPageFlow pageName="p_protocolconfsummary" />
<%@ include file="/inc/CatchError.inc"%>

<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/cn/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/opal2/mootools.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/opal2/opal2.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/opal2/DBGrid.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %> 
<%
	HashMap pageconfiginfo = (HashMap)pageContext.getAttribute("pageconfiginfo");
	if(pageconfiginfo == null) pageconfiginfo = new HashMap();
	String type = "";
	int selectmode = ((Integer)pageconfiginfo.get("selectmode")).intValue();
	switch(selectmode){
		case 1: type = "checkbox"; break;
		case 2: type = "radio";break;
		case 3: break;
	}
	String dataIdColumn = (String)pageconfiginfo.get("dataIdColumn");
%> 
<script language="JavaScript">

function indicatorClick(item){
	document.cform.protocolid.value=item.value;
}
var dbGrid = null;
function page_summary(actionvalue,orderbyname){
	var editform = summaryPrepare(document.cform,actionvalue,orderbyname);
	var myHTMLRequest = new Request({
	url:'<%=contextPath%>/Dispatcher',
	onComplete: function(responseText,responseXML) {
		var data = JSON.decode(responseText);  //获取后台生成的对象	
		dbGrid.reload(data);
		dbGrid.setDefaultSelected(0);
		var isfirst = data.isfirst;
		dbGrid.setHiddenItemValue('isfirst', isfirst);
	}
						
	}).send($('cform').toQueryString());    
}
document.addEvent('domready', function (){
	
	dbGrid = new opal.widget.DBGrid({
				'id': 'protocolgrid', //change id
				'data': null,
				'summaryDataName': 'protocols', //change
				'descColumnsName': 'columndesc',
				'indicator': {'type': '<%=type%>', 'dataIdColumn': '<%=dataIdColumn%>'}
			});
			dbGrid.display();		
			dbGrid.indicatorClick = indicatorClick;
			page_summary('search');	
});

<%--  put your custom script here   --%>
<%-- 
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  if(!editform) return;
  editform.action = "ProtocolManagement.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}
--%>
function page_edit()
{
	if(null!=document.cform.protocolid){
	var protocolid = document.cform.protocolid.value;
	var status = document.cform.status.value;
	if(status != 10){
		alert("<%= message.getMessageDesc("CAN_NOT_EDIT_IT") %>");
		return;
	}
	self.location.href="ProtocolEditFrm.jsp?<%= OvalTools.randomURL() %>&protocolid="+protocolid;
	}else{
		alert('<%=message.getMessageDesc("PLEASE_SELECT")%>');
	}
}

function page_new()
{
    self.location.href="ProtocolEditFrm.jsp?<%= OvalTools.randomURL() %>";
}

function page_delete()
{
if(null!=document.cform.protocolid){
	var status = document.cform.status.value;
	if(status != 10){
		alert("<%= message.getMessageDesc("CAN_NOT_BE_DEL") %>");
		return;
	}
    if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>")) return;
    cform.actionname.value = "delete";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
    
    }else{
		alert('<%=message.getMessageDesc("PLEASE_SELECT")%>');
	}
}
function clickonerow(obj,id,status){
	obj.all.protocol.checked = true;
	document.cform.protocolid.value=id;
	document.cform.status.value=status;
}
function popOrg(flag) {
	var opt="";
	if(isEmpty(document.cform.protocoltype.value))
    {
        alert("<%= message.getMessageDesc("Please_Choose_The_Type_Of_Agreement") %>");		
        return;
    }
	if(flag == 1)
	{
			opt = "1";
	}else
	{
			opt = "2";
	}
  var status = "height=400, width=600, top=100, left=100, toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no";
		var url = "SelectClient.jsp?o_thread=" + Math.random();
		url += "&selectoption=distributor&orgglobalpccode=100";
		url += "&opt=" + opt;
		url += "&protocoltype="+document.cform.protocoltype.value;
		if (typeof popwindow != 'undefined') popwindow.close();
		popwindow = window.open(url, "newwindow", status);
}


function page_test(){
	cform.actionname.value = "test";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}

function showPopWindow (pagename){
	var status = "height=250, width=600, top=100, left=100, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes, location=yes, status=yes";
	var url = pagename+'?<%= OvalTools.randomURL() %>';	
	popwindow = window.open(url, "newwindow", status);
}

function popSelectRegionWindow(){
	 showPopWindow ('../ogm/RegionPopWindow.jsp');	
}

function showPopProWindow (pagename,areaidString){
	var status = "height=250, width=600, top=100, left=100, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes, location=yes, status=yes";
		var url = pagename+'?<%= OvalTools.randomURL() %>' + '&areaidstring=' + areaidString;
		
	popwindow = window.open(url, "newwindow", status);
}

function popSelectProWindow(){
		 var areaname = document.cform.areaname.value;
		 var areaidString = document.cform.areaids.value;
		 if(areaname == "" || areaname.length == 0){
			alert("请选择大区！");
		 	document.cform.areaname.focus();
		 	return;
		 }
		 showPopProWindow ('../ogm/ProvincePopWindow.jsp',areaidString);
}

function setNewAreaCode(newareacode,areaname,areacode){
	var length = newareacode.length;
	var areaidString = "";
	var areanameString = "";
	var areacodeString = "";
	document.cform.areaname2.value = "";
	document.cform.areaids2.value = "";	
	for(var i = 0;i < length;i++){
		if(i == length - 1){
			areaidString = areaidString + newareacode[i].value;
			areanameString = areanameString + areaname[i].value;
			areacodeString = areacodeString+ areacode[i].value;
		}else{				
			var code = newareacode[i];				
			areaidString = areaidString + newareacode[i].value + ",";
			areanameString = areanameString + areaname[i].value + ",";
			areacodeString = areacodeString + areacode[i].value + ",";
		}			
	}	
	document.cform.areaname.value = areanameString;
	document.cform.areaids.value = areaidString;	
}
function setNewRegionCode(newareacode,areaname2,areacode2){
	var length = newareacode.length;
	var areaidString = "";
	var areanameString = "";
	var areacodeString = "";
	for(var i = 0;i < length;i++){
		if(i == length - 1){
			areaidString = areaidString + newareacode[i].value;
			areanameString = areanameString + areaname2[i].value;
			areacodeString = areacodeString+ areacode2[i].value;
		}else{				
			var code = newareacode[i];				
			areaidString = areaidString + newareacode[i].value + ",";
			areanameString = areanameString + areaname2[i].value + ",";
			areacodeString = areacodeString + areacode2[i].value + ",";
		}			
	}
	
	document.cform.areaname2.value = areanameString;
	document.cform.areaids2.value = areaidString;	
}
function page_copy(){
	if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE_COPY") %>")) return;
	cform.actionname.value = "copy";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}	
</script>
</head>

<body >
<form name="cform" id="cform" method="post" action="<%=contextPath%>/Dispatcher">
<input type="hidden" name="pagename" value="p_protocolconfsummary"/> 
<input type="hidden" name="actionname" value="ajax"/>
<input type="hidden" name="name" value=""/>
<input type="hidden" name="type" value=""/>
<input type="hidden" name="isfirst" id="isfirst" value="Y"/>
<custom:hidden property="languagecode" scope="session"/>
<%--  page location   --%>
<%@ include file="/inc/PageLocation.inc"%>

<table width="100%" cellspacing="0" border="0" cellpadding="0">
	
	<tr>
		<td>
		<table width="100%" border="0" cellspacing="0">
			<%@ include file="/inc/SummarySearch.inc"%>
		</table>
		</td>
	</tr>		
		<%--<input type="hidden" name="protocolid" value="<%= nDefaultProtocolid %>"/>
		<input type="hidden" name="status" value="<%= nStatus%>"/>--%>
				
	  <tr> 
	  	 <td> 
	      <div id="protocolgrid"></div>
			<table width="100%" cellspacing="0" cellpadding="0">
			<tr>
				<td class="summary_top"></td>
			</tr>
			<tr>
				<td class="td_center"><a onclick="page_new();"><custom:button
					type="1" label="L_New" imgsrc="new.gif" border="0" style="width:60" /></a>
					 <a onclick="page_edit()"><custom:button type="1" label="L_Edit" imgsrc="edit.gif" border="0" style="width:60" /></a> 
					 <!-- 
					 <a onclick="page_copy()"><custom:button type="1" label="L_Copy" imgsrc="edit.gif" border="0" style="width:60" /></a>
					 -->
					 <a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60" /></a> 
				</td>
			</tr>
          </table>
        </td>
      </tr>
    </table>
</form>
</body>
</html>